home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / desktop / dibquant.zip / LOCAL.H < prev    next >
C/C++ Source or Header  |  1994-06-17  |  3KB  |  102 lines

  1. ///////////////////////////////////////////////////////////////////////////
  2. // DIBQuant version 1.0
  3. // Copyright (c) 1993 Edward McCreary.
  4. // All rights reserved.
  5. //
  6. // Redistribution and use in source and binary forms are freely permitted
  7. // provided that the above copyright notice and attibution and date of work
  8. // and this paragraph are duplicated in all such forms.
  9. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  10. // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  11. // WARRANTIES OF MERCHANTIBILILTY AND FITNESS FOR A PARTICULAR PURPOSE.
  12. ///////////////////////////////////////////////////////////////////////////
  13.  
  14. #ifndef _LOCAL_H
  15. #define _LOCAL_H
  16.  
  17. #ifndef MIN
  18. #define MIN(a,b) ((a)<(b)?(a):(b))
  19. #endif
  20.  
  21. #ifndef MAX
  22. #define MAX(a,b) ((a)>(b)?(a):(b))
  23. #endif
  24.  
  25. #define CLIP(x) ((x)>255?255:((x)<0?0:(x)))
  26.  
  27. #define COLOR_MAX 32
  28.  
  29. #define COUNT_LIMIT 0xFFFFL
  30.  
  31. typedef struct box
  32. {
  33.  int r0,r1,g0,g1,b0,b1;
  34.  long rave,gave,bave;
  35.  unsigned long count;
  36. } Box;
  37.  
  38. typedef struct node
  39. {
  40.  int            index;
  41.  unsigned long count; 
  42. } Node, FAR *LPNode;
  43.  
  44.  
  45. typedef struct tagBuffers
  46. {
  47.   FARPROC   lpStatus;
  48.   int red[256],green[256],blue[256];
  49.   Box     box[256];
  50.   long SQR[256];
  51.   LPNode huge *lpHisto;
  52.   
  53. } QUANT_BUFFER, FAR *LPQUANT_BUFFER;
  54.  
  55. #define SWAP(a, b)    { unsigned long   tmp;            \
  56.             tmp = a; a = b; b = tmp; }
  57.  
  58. #define INDEX(r,g,b) (((DWORD)b) | (((DWORD)g)<<5) | (((DWORD)r)<<10) )
  59.  
  60. #define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)
  61. #define IS_WIN30_DIB(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
  62.  
  63. #define JITTER_TABLE_BITS   10
  64. #define JITTER_TABLE_SIZE   (1<<JITTER_TABLE_BITS)
  65. #define JITTER_MASK         (JITTER_TABLE_SIZE-1)
  66.  
  67. /* jitter macros */
  68. #define jitterx(x,y,s) \
  69. (uranx[((x+(y<<2))+irand[(x+s)&JITTER_MASK])&JITTER_MASK])
  70. #define jittery(x,y,s) \
  71. (urany[((y+(x<<2))+irand[(y+s)&JITTER_MASK])&JITTER_MASK])
  72.  
  73.  
  74. #define STATUS_CAST void (FAR PASCAL *)(LPCSTR)
  75.  
  76.  
  77. ///////////////////////////////////////////////////////////////////////////
  78. // local prototypes
  79. void m_box(LPQUANT_BUFFER lpBuffer);
  80. void make_box(int r, int g, int b, int index, unsigned long c,LPQUANT_BUFFER lpBuffer);
  81. void squeeze(int b,LPQUANT_BUFFER lpBuffer);
  82. void add_color(int r, int g, int b, unsigned long c,LPQUANT_BUFFER lpBuffer);
  83. void force(int r, int g, int b, unsigned long c,LPQUANT_BUFFER lpBuffer);
  84. void pop(LPQUANT_BUFFER lpBuffer);
  85.  
  86. int GetNeighbor(int r,int g,int b,LPQUANT_BUFFER lpBuffer);
  87. void ClearLUT(LPQUANT_BUFFER lpBuffers);
  88. LPQUANT_BUFFER InitLUT();
  89.  
  90. LPSTR Dither(LPSTR lpDIB,int nDither,LPQUANT_BUFFER lpBuffer);
  91.  
  92. LPSTR AllocNewDIB(LPSTR lpDIB,LPQUANT_BUFFER lpBuffer);
  93.  
  94. void jitter(long x, long y, int *r,int *g,int *b);
  95.  
  96. void LoadDefaultPal(LPQUANT_BUFFER lpBuffer);
  97. WORD FAR DIBNumColors(LPSTR lpDIB);
  98. WORD FAR PaletteSize(LPSTR lpDIB);
  99. LPSTR FAR FindDIBBits(LPSTR lpDIB);
  100.  
  101.  
  102. #endif /* _LOCAL_H */